/*
$.validator.setDefaults({
	submitHandler: function() { alert("submitted!"); }
});
*/
$(document).ready(function(){
	
   var need = 0;
   
   $("#taskForm").validate({
	   // debug: true,       //调试模式取消submit的默认提交功能 
	   // onkeyup: false,    //取消当键盘按键弹起时的验证
	    //focusCleanup: true,
	   // onfocusout:false,
	    onsubmit: false,
	    //onclick: false,
	    submitHandler: function(form){     
              alert("已经添加新任务！");
        },
        errorPlacement: function(error, element) {  //验证消息放置的地方   
            error.appendTo( element.parent("td").next("td") );   
        },      
        success: function(label) {     
                    label.addClass("valid").text("Ok!");
        	        
                    need++;
                   // alert(need);
        },
		rules: {
			taskName:{
			          required: true
			},
			taskContext: 'required',
			taskLeader: 'required',
			taskPeople: 'required',
			taskRes: "required",
			taskTime: "required",
			fileField:{
			    required: true,   
                accept: "xls,doc,rar,zip"
			}
		},
		messages: {
			taskName: {required:"*请输入任务名称！"
			} ,
			taskContext: {required:"*请输入任务内容！"
			} ,
			taskLeader:{required:"*请选择任务负责人！"
			} ,
			taskPeople:{required:"*请选择负责任务的其他人员！"
			} ,
			taskRes: {required:"*请选择完成任务的必须资源！"
			} ,
			taskTime:{required:"*请输入任务的分派时间！"
			},
			fileField:{ required: "*请上传任务详情的附件！",   
                        accept: "*只接收xls,doc,rar,zip文件"  
			}
		}

    });
   

		
		
});
	